home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
AUTOCAD
/
H107.ZIP
/
APR91.ZIP
/
BOLT.LSP
< prev
next >
Wrap
Text File
|
1991-05-13
|
7KB
|
205 lines
; BOLT.LSP [Article Figure 5] (c)1991, Barry Bowen
;**************************************************************
; BOLT.LSP
; Bolt program
; Copyright (c) Barry R. Bowen
; --------------------- GETSIZE -------------------------------
; Get Bolt or Nut Size
(defun GETSIZE ()
(initget 1 "B N")
(setq HEX (getkword "\n<B>olt or <N>ut: "))
(if (= HEX "B")
(progn
(prompt "\n1/4 5/16 3/8 7/16 1/2 5/8 3/4 7/8")
(prompt "\n1.0 1.125 1.25 1.375 1.5 1.75 2.0 2.25")
(setq SIZE (getstring "\nNominal Size of Hex Bolt: "))
(BEGIN "HBOLT.DAT")
)
(progn
(prompt
"\n1/4 5/16 3/8 7/16 1/2 9/16 5/8 3/4 7/8")
(prompt "\n1.0 1.125 1.25 1.375 1.5")
(setq SIZE (getstring "\nNominal Size of Hex Nut: "))
(BEGIN "HNUT.DAT")
))
)
; ----------------------- BEGIN -------------------------------
; Start-up routine
(defun BEGIN (DATA)
(if (not MPT) (setq MPT (getpoint "\nInsertion Point: ")))
(setq CK nil EN (entlast)
FILE (open DATA "r")
SL (strlen SIZE)
LINE (read-line FILE))
(while (and LINE (/= SIZE (substr LINE 1 SL)))
(setq LINE (read-line FILE)))
(close FILE)
(if (not (member LINE '(nil "")))
(if (= SIZE (substr LINE 1 SL))
(progn (GETDAT) (setq CK T)))
(prompt "\nRequested Size Not found!")
) (princ)
)
; ----------------------- GETDAT ------------------------------
; Get Data from required file
(defun GETDAT ()
(setq BN (substr LINE 11 10))
(STRBN)
(setq S1 (atof (substr LINE 21 10))
S2 (atof (substr LINE 31 10))
S3 (atof (substr LINE 41 10))
S4 (atof (substr LINE 51 10))
S5 (atof (substr LINE 61 10)))
)
; ----------------------- STRBN -------------------------------
; Get block name
(defun STRBN ()
(setq LGTH 1 TSTR (strlen BN)
CH (substr BN LGTH 1))
(while (and (/= CH " ") (/= CH ""))
(setq LGTH (1+ LGTH) CH (substr BN LGTH 1)))
(setq BN (substr BN 1 (1- LGTH)))
(if (= VIEW "EL") (setq BN (strcat VIEW BN)))
)
; ----------------------- HBOLTP ------------------------------
; Hex Bolt or Hex Nut drawn in Plan view
(defun C:HBOLTP (/ CK SS1)
(V3)
(GETSIZE)
(if (= CK T) (progn
(if (= (tblsearch "block" BN) nil)
(progn
(command "insert" "HBOLTP" MPT S2 S2 0
"block" BN MPT (entlast) ""
"insert" BN MPT 1 1 0)
) ;End Progn
(command "insert" BN MPT 1 1 0)
) ) )
(setq ANS (getstring "\nAdd Washer <Y>? "))
(if (or (= ANS "") (= ANS "Y") (= ANS "y")) (WASHP))
(setq MPT nil)
(V4)
)
; ----------------------- HBOLTE ------------------------------
; Hex Bolt drawn in Elevation view
(defun C:HBOLTE (/ CK SS1 HEX SIZE)
(V3)
(setq VIEW "EL")
(GETSIZE)
(if (= CK T) (progn
(setq ANG (getangle "\nRotation Angle: ")
ANG (angtos ANG))
(if (= (tblsearch "block" BN) nil)
(progn
(setq G1 (/ S2 2.0)
G2 (/ S2 4.0)
G3 (/ S2 8.0)
PT1 (polar MPT pi G1)
PT2 (polar PT1 0 S2)
PT3 (polar (polar PT1 0 G3) (D90) S3)
PT4 (polar (polar PT2 pi G3) (D90) S3)
PT1A (polar PT1 (D90) 1.0)
PT3A (polar PT3 3.66519 1.0)
PT5 (inters PT1 PT1A PT3 PT3A nil)
PT6 (polar PT1 0 G2)
DIST (distance PT1 PT5)
DIFF (- S3 DIST)
PT7 (polar PT6 (D90) DIST)
PT8 (polar PT2 pi G2)
PT9 (polar PT8 (D90) DIST)
PT10 (polar PT2 (D90) DIST)
PT11 (polar PT1 (D90) DIFF)
PT11A (polar PT1 0 G3)
PT12 (polar PT6 (D90) DIFF)
PT13 (polar PT8 (D90) DIFF)
PT13A (polar PT8 0 G3)
PT14 (polar PT2 (D90) DIFF)
MPT1 (polar MPT (D90) S3)
)
(setq EN (entlast))
(command "pline" PT10 "a" "s" PT4 PT9 "s" MPT1 PT7
"s" PT3 PT5 ""
"line" PT3 PT4 "")
(if (= HEX "B") (progn
(command "line" PT5 PT1 PT2 PT10 ""
"line" PT6 PT7 ""
"line" PT8 PT9 ""))
(progn
(command "pline" PT11 "a" "s" PT11A PT12
"s" MPT PT13 "s" PT13A PT14 ""
"line" PT11A PT13A ""
"line" PT11 PT5 ""
"line" PT12 PT7 ""
"line" PT13 PT9 ""
"line" PT14 PT10 "")
) )
(MKSET)
(command "block" BN MPT SS1 "")
(command "insert" BN MPT 1 1 ANG)
)
(command "insert" BN MPT 1 1 ANG)
) ) )
(setq ANS (getstring "\nAdd Washer <Y>? "))
(if (or (= ANS "") (= ANS "Y") (= ANS "y")) (WASHE))
(setq MPT nil VIEW nil)
(V4)
)
; ------------------------ WASHE ------------------------------
; Washer drawn in Elevation View
(defun WASHE (/ CK SS1)
(V3)
(setq VIEW "EL")
(BEGIN "AWASHER.DAT")
(if (= CK T) (progn
(if (= (tblsearch "block" BN) nil)
(progn
(command "insert" "WASHEL" MPT S1 S2 0
"block" BN MPT (entlast) ""
"insert" BN MPT 1 1 ANG)
) (command "insert" BN MPT 1 1 ANG)
) ) )
(setq MPT nil VIEW nil)
(V4)
)
; ------------------------ WASHP ------------------------------
; Washer drawn in Plan View
(defun WASHP (/ CK SS1)
(V3)
(BEGIN "AWASHER.DAT")
(if (= CK T) (progn
(if (= (tblsearch "block" BN) nil)
(progn
(command "circle" MPT "d" S1
"block" BN MPT (entlast) ""
"insert" BN MPT 1 1 0)
) (command "insert" BN MPT 1 1 0)
) ) ) (V4)
)
; ------------------------ MKSET ------------------------------
; Make a selection-set of all entities
(defun MKSET ()
(setq SS1 (ssadd) EN1 (entnext EN))
(while EN
(setq SS1 (ssadd EN1 SS1)
EN1 (entnext EN)
EN EN1))
)
(defun D90 () (* pi 0.5))
; ------------------------ V3.LSP -----------------------------
(defun V3 ()
(setq BM (getvar "blipmode")) ;Current Blipmode setting
(setvar "blipmode" 0) ;Turn Blips off
(setvar "cmdecho" 0) ;Turn command echo off
(command "undo" "group") ;Necessary for correct UNDO
;of program being executed
)
; ------------------------ V4.LSP -----------------------------
(defun V4 (/ BA)
(setvar "blipmode" BM) ;Reset to original setting
(command "undo" "end") ;End of UNDO sequence
(prompt "\n") ;New line
(setq BA "Program Completed. . . . .") ;Prints string
)